from typing import Any

from fastapi import Depends
from starlette.requests import Request

from common.utils import verif_oauth
from schemas.user import UserInSchem
from schemas.user import EmailSchema
from schemas.user import Login
from service.user import UserService


class UserController:

    @classmethod
    async def user_info(cls, token: Any = Depends(verif_oauth)):
        return await UserService.current_user(token)

    @classmethod
    async def register_user(cls, user: UserInSchem):
        return await UserService.register(user)

    @classmethod
    async def login_user(cls, user: Login):
        return await UserService.login(user)

    @classmethod
    async def update_email(cls, email: EmailSchema, token: Any = Depends(verif_oauth)):
        return await UserService.update_email(token.get("id"), email)

    @classmethod
    async def active_email(cls, token: str):
        return await UserService.active_email(token)